package com.dream;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;

import com.alibaba.druid.pool.DruidDataSource;

@SpringBootApplication
@PropertySource(value="classpath:db.properties",ignoreResourceNotFound=true)
public class DataSourceConfig {
	
	@Value("${jdbc.jdbcUrl}")
	private String jdbcUrl;
	
	@Value("${jdbc.driverClass}")
	private String driverClassName;
	
	@Value("${jdbc.username}")
	private String username;
	
	@Value("${jdbc.password}")
	private String password;

	@Bean
	public DataSource dataSource() {
		DruidDataSource ds = new DruidDataSource();
     	ds.setUrl(jdbcUrl);
     	ds.setDriverClassName(driverClassName);
     	ds.setUsername(username);
     	ds.setPassword(password);
     	return ds;
	}
}
